package com.shop.cereshop.commons.enums.agreement;

import lombok.Getter;

/**
 * @description: 协议版本枚举类
 * @author lx
 * @date 2025/10/17 10:44
 * @version 1.0
 */
@Getter
public enum AgreementVersionEnum {

    USER(1, "user"),
    MERCHANT(2, "merchant"),
    AGENT(3, "agent"),
    SALESPERSON(4, "salesperson")
    ;    

    private final Integer code;

    private final String msg;

    AgreementVersionEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    
    public static AgreementVersionEnum getByCode(Integer code) {
        for (AgreementVersionEnum value : AgreementVersionEnum.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }
    
    public static String getMsgByCode(Integer code) {
        for (AgreementVersionEnum value : AgreementVersionEnum.values()) {
            if (value.getCode().equals(code)) {
                return value.getMsg();
            }
        }
        return null;
    }
    
    public static Integer getCodeByMsg(String msg) {
        for (AgreementVersionEnum value : AgreementVersionEnum.values()) {
            if (value.getMsg().equals(msg)) {
                return value.getCode();
            }
        }
        return -1;
    }
}
